package com.hst.web.base.proxy;

import java.util.ArrayList;
import java.util.List;

import org.apache.commons.beanutils.BeanUtils;
import org.springframework.beans.factory.annotation.Autowired;

import com.hst.core.dao.IORDao;
import com.hst.core.dao.ORQuery;
import com.hst.core.meta.MetaData;
import com.hst.core.meta.proxies.DefaultDataProxy;
import com.hst.web.base.entity.TReivewHistory;
import com.hst.web.base.entity.TVehicleInfo;
import com.hst.web.base.ui.CompanyVehicleReviewConfirmCompany;

public class CompanyVehicleReviewConfirmCompanyProxy extends DefaultDataProxy{
	
	@Autowired
	IORDao dao;

	@SuppressWarnings("unused")
	@Override
	public Object save(MetaData data) throws Exception {
		List<ORQuery> querys = new ArrayList<ORQuery>();
		
		CompanyVehicleReviewConfirmCompany e = (CompanyVehicleReviewConfirmCompany) data;
		
		String vehicleCode = e.getVehicleCode();
		
		TVehicleInfo vehicleInfo= dao.get(TVehicleInfo.class, vehicleCode);
		BeanUtils.copyProperties(vehicleInfo, e);
		dao.save(vehicleInfo);
		
		TReivewHistory reivewHistory = new TReivewHistory();
		BeanUtils.copyProperties(reivewHistory, e);
		dao.save(reivewHistory);
		
		return e;
	}
}
